package com.kgc.ssm.service.Impl;

import com.kgc.ssm.beans.User;
import com.kgc.ssm.mapper.UserMapper;
import com.kgc.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @date 2021/11/24 10:00
 * @Description:用户业务实现类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> selectAllUser() {
        return userMapper.selectAllUser();
    }

    @Override
    public Integer insertUser(User user) {
        if(userMapper.insertUser(user)){
            return 1;
        }
        return 0;
    }

    @Override
    public Integer selectOneUser(String uid) {
        return userMapper.selectOneUser(uid);
    }

    @Override
    public Integer selectAssignedUser(String uid, String pwd) {
        if (userMapper.selectAssignedUser(uid, pwd) != null){
            return 1;
        }
        return 0;
    }

    @Override
    public boolean afterLogin(String usernmae, String password) {
        Integer uuser = userMapper.afterLogin(usernmae,password);
        if (uuser!=0){
            return true;
        }else{
            return false;
        }
    }
}
